<template>

    <tableCommon :tableData="tableData" :tableColumns="tableColumns" :total="total" :pageNumber="pageNumber"
                 :condtions="condtions" @pick="pick" @show="show"
                 @acquireItems="acquireItems"></tableCommon>
</template>

<script>
    import tableCommon from './tableCommon.vue';

    import axios from 'axios';

    export default {

        components: {tableCommon},

        data(){
            return {
                total: null,
                pageNumber: 1,
                tableData: [],
                tableColumns: [{
                    title: 'title',
                    key: 'title',
                },
                    {
                        title: 'content',
                        key: 'content',
                        ellipsis: true
                    },
                    {
                        title: 'author',
                        key: 'author'
                    },
                    {
                        title: 'collected_count',
                        key: 'collected_count'
                    },
                    {
                        title: 'page_url',
                        key: 'page_url',
                        ellipsis: true,
                        render(row)
                        {
                            return `<a href="${row.page_url}" target="_blank">${row.page_url}</a>`;
                        }

                    }],
                condtions: {
                    title: {},
                    content: {},
                    author: {},
                    collected_count: {},
                    page_url: {}
                }
            };
        },
        methods: {
            pick(selection){
                this.$Modal.info({
                    content: JSON.stringify(selection)
                });
            },
            show(data){
                this.$Modal.info({
                    content: JSON.stringify(data)
                });
            },
            acquireItems(page, condtion){
                let me = this;
                axios.get('/zhidaoItem', {
                    params: {
                        page: page,
                        condtion: condtion
                    }
                })
                        .then(function (response) {

                            var data = response.data;

                            me.total = data.totalRow;

                            me.tableData = data.list;

                            me.pageNumber = data.pageNumber;

                            console.log(response);
                        })
                        .catch(function (error) {
                            console.log(error);
                        });
            }

        }

    }


</script>